<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="Generator" content="EditPlus®">
    <meta name="Author" content="">
    <meta name="Keywords" content="">
    <meta name="Description" content="">

    <title>canvas场景连线特效</title>
    <style type="text/css">
        * {
            margin: 0px;
            padding: 0px;

        }

        body {
            background: linear-gradient(#5586e2, #ebedf0);
            display: flex;
            justify-content: center;
            align-items: center;
            /* 让页面始终占浏览器可视区域总高度 */
            height: 100vh;

        }

        .de, .login, .register {
            width: 400px;
            height: 300px;
            padding: 40px;
        }

        .de {
            transform-style: preserve-3d;
            transition: all 1s;
            position: relative;
        }

        .login {
            backface-visibility: hidden;
        }

        .login, .register {
            /* 弹性布局 让子元素称为弹性项目 */
            display: flex;
            /* 让弹性项目垂直排列 原理是改变弹性盒子的主轴方向 父元素就是弹性盒子 现在改变后的主轴方向是向下了 */
            flex-direction: column;
            /* 让弹性项目在交叉轴方向水平居中 现在主轴的方向是向下 交叉轴的方向是与主轴垂直 交叉轴的方向是向右 */
            align-items: center;
            left: 0;
            top: 0;
            background-color: rgba(255, 255, 255, 0.4);
            box-shadow: 0 5px 15px rgba(20, 20, 20, 0.8);
            border-radius: 23px;
            position: absolute;

        }

        .login h2, .register h2 {
            color: #fff;
            margin-bottom: 30px;
        }

        .login_box {
            position: relative;
            width: 80%;
        }

        .login_box input {
            outline: none;
            border: none;
            width: 100%;
            padding: 10px 0;
            margin-bottom: 30px;
            color: #fff;
            font-size: 16px;
            border-bottom: 1px solid #fff;
            background-color: transparent;
        }

        .login_box label {
            float: left;
            position: absolute;
            top: 0;
            left: 0;
            padding: 10px 0;
            color: #fff;
            pointer-events: none;
            transition: all 1s;
        }

        .login_box input:focus + label,
        .login_box input:valid + label {
            font-size: 14px;
            top: -20px;
            color: rgb(235, 13, 13);
        }

        .login_but button {
            overflow: hidden;
            position: relative;
            padding: 10px 20px;
            color: #03e9f4;
            /* 取消a表现原有的下划线 */
            background-color: transparent;
            border: none;
            cursor: pointer;
        }

        .login_but button:hover {
            color: #fff;
            border-radius: 5px;
            background-color: #03e9f4;
            box-shadow: 0 0 5px #03e9f4, 0 0 25px #03e9f4, 0 0 50px #03e9f4,
            0 0 100px #03e9f4;
        }

        .register {
            transform: translateZ(-100px) rotateY(180deg);
            backface-visibility: hidden;
        }

        .validate-inline {
            color: red;
            position: absolute;
            left: 77%;
            top: 15px;
            font-size: 10px;
        }

        .input-val {
            width: 100px;
            height: 43px;
            text-align: center;
            font-size: 20px;
            background: #ffffff;
            border-radius: 5px;
            border: 1px solid rgba(0, 0, 0, .2);
            float: left;
        }

        #canvas {
            float: left;
            margin-left: 20px;
        }

        .fe {
            float: left;
            font-size: 10px;
            color: red;
            top: 10px;
            margin-left: 24px;
            margin-top: 10px;
        }
    </style>
</head>
<body>
<div class="de" id="de">
    <form action="#" id="go_form" class="login">
        <div><h2>用户登录</h2></div>
        <div class="login_box">
            <input id="username" name="username" required style="position: relative"><label>用户名：</label>
            <span for="username"></span>
        </div>
        <div class="login_box">
            <input id="password" name="password" required style="position: relative"><label>密码：</label>
            <span for="password"></span>
        </div>
        <div style="margin-bottom: 20px;width: 80%">
            <input type="text" value="" class="input-val"/>
            <canvas id="canvas" width="100" height="43"></canvas>
            <span id="fe" class="fe"></span>
        </div>
        <div class="login_but">
            <button type="submit" id="login">登录</button>
            <button onclick="de()">注册</button>
        </div>
    </form>
    <div class="register">

        <div><h2>用户注册</h2></div>
        <div class="login_box">
            <input required><label>用户名：</label>
        </div>
        <div class="login_box">
            <input required><label>密码：</label>
        </div>
        <div class="login_box">
            <input required><label>确认密码：</label>
        </div>
        <div class="login_but">
            <button onclick="gr()">返回登录</button>
            <button onclick="register()">注册</button>
        </div>
    </div>

</div>
<!-- <canvas id="c_n9" width="1366" height="403" style="position: fixed; top: 0px; left: 0px; z-index: -1; opacity: 0.5;"></canvas> -->
<script type="text/javascript" src="../static/js/test-clear.js" opacity=20></script>
<script src="../static/js/jquery-1.10.1.min.js"></script>
<script src="../static/js/jquery.validate.min.js"></script>
<script src="../static/js/code.js"></script>
</body>
<script>
    function de() {
        document.getElementById('de').style.transform = 'rotateY(180deg)'
    }

    function gr() {
        document.getElementById('de').style.removeProperty('transform')
    }

    $(function () {
        $("#go_form").validate({
            focusCleanup: true,
            errorElement: 'span',
            errorClass: 'validate-inline',
            rules: {
                username: {
                    required: true
                },
                // password: {
                //     required: true
                // },
            },
            messages: {
                username: {
                    required: "请输入用户名"
                },
                password: {
                    required: "请输入密码"
                },
            },
            errorPlacement: function (error, element) {
                // Append error within linked label
                $(element)
                    .closest("form")
                    .find("span[for='" + element.attr("id") + "']")
                    .append(error);
            },

            highlight: function (element) {
                $(element).closest('.login_box').removeClass('success').addClass('error');
            },
        })
    })

    $(function () {
        code_draw();
        // 点击后刷新验证码
        $("#canvas").on('click', function () {
            code_draw();
        })
        $("#login").on('click', function () {
            // 将输入的内容转为大写，可通过这步进行大小写验证
            var val = $(".input-val").val().toLowerCase();
            // 获取生成验证码值
            var num = $('#canvas').attr('data-code');
            if (val == '') {
                document.getElementById("fe").innerHTML = "请填写验证码";
            } else if (val == num) {
                document.getElementById("fe").innerHTML = "验证码正确";
                $(".input-val").val(num);
            } else {
                document.getElementById("fe").innerHTML = '验证码错误';
                $(".input-val").val('');
            }
        })
    })
</script>
</html>